package chen.web.test.blog;

import org.springframework.context.ApplicationContext;

import chen.web.blog.Blog;
import chen.web.blog.BlogManager;
import chen.web.blog.Category;
import chen.web.user.Account;

public class BlogTestUtils {

    private ApplicationContext applicationContext;
	public BlogTestUtils(ApplicationContext applicationContext){
		this.applicationContext = applicationContext;
	}
	
	public Blog setupBlog(Account owner){
		Blog blog = new Blog(owner);
		blog.setName("hello");
		blog.setDescription("hello");
		BlogManager bm = applicationContext.getBean(BlogManager.class);
		return bm.create(blog);
	}
	public void teardownBlog(Blog blog){
		BlogManager bm = applicationContext.getBean(BlogManager.class);
		bm.deleteBlog(blog);
	}
}
